package com.dxy.lc.model.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.time.LocalDateTime;

import com.dxy.lc.model.bean.TreeVo;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * <p>
 * 
 * </p>
 *
 * @author dxy
 * @since 2024-11-07
 */
@Getter
@Setter
@Accessors(chain = true)
@TableName("t_dept")
public class Dept {

    @TableId(value = "id", type = IdType.INPUT)
    private String id;

    private String name;

    private Integer sort;

    private String parentId;

    private String description;

    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createdAt;

    @TableField(fill = FieldFill.INSERT)
    private Integer createdBy;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updatedAt;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Integer updatedBy;

    @TableField(exist = false)
    private String parentDeptName;

    public TreeVo toTreeVo(){
        return new TreeVo()
                .setId(this.id)
                .setParentId(this.parentId)
                .setText(this.name)
                .setSort(this.sort)
                .setNodeType(TreeVo.NODE_TYPE_DEPT)
                .setVal(this);
    }
}
